package SendRedBag;

import java.util.ArrayList;

/* 群主 */
public class Manager extends User {
    //构造方法
    public Manager() {

    }

    /* 发红包
        sendeMoney 要发送的红包
        count :要发的个数
      */
    public ArrayList send(Integer sendMoney , int count){
        Integer totalMoney = super.getMoney();

        //余额不足
        if (sendMoney > totalMoney){
            System.out.println("余额不足");
            return new ArrayList();
        }
        //余额足够
        ArrayList moneyList = new ArrayList();//储存红包的数组
        for (int i = 0; i < count; i++) {
            //获得 红包
            Integer money = sendMoney / count;
            //将没有除尽的钱放在最后一个红包里面
            if (i == count - 1){
                money = money + sendMoney % count;
            }
            moneyList.add(money);
        }
        //红包发完了
        super.setMoney(totalMoney- sendMoney);//群主余额

        return moneyList;
    }


}
